<!-- 余额 -->
<template>
    <view class="container">
        <header-bar :config="config" @rightClick="rightClick"></header-bar>
        <view class="balance-info">
            <view class="name">总余额（仅启用）</view>
            <view class="total"> <text>¥</text>{{ balance }} </view>
            <view class="acct-num"> 共{{ datas.length }}个账户 </view>
            <image src="/static/img/erp/icon_dz.png" class="icon-dz"></image>
        </view>
        <!-- <search-bar ref="orderSearch" :placeholderText="placeholderText"  @searchFn="searchFn"
			:actions="actions" @actionFn="filterOpen">
		</search-bar> -->
        <view class="main">
            <account-list ref="accountList" :height="listHeight" @totalBack="waitTotalBack"></account-list>
            <!-- <view class="list-box">
				<view class="list-item" @tap="toList(item)" v-for="(item,index) in datas" :key="index">
                    <view class="name">
                        {{item.AName}}
                    </view>
                    <view class="con">
                        <view class="num">
                            ¥{{item.Total}}
                        </view>
                        <uni-icons class="icon-arrow-right" type="arrowright"></uni-icons>
                    </view>
                </view>
			</view> -->
        </view>
    </view>
</template>

<script>
import { getElementHeight } from "@/uni-sub-base/utils/elementUtil.js"
import searchBar from "@/components/common/search-bar.vue"
import { getAccountList } from "@/service/api/erp.js"
import accountList from "./account-list.vue"
export default {
    components: {
        searchBar,
        accountList,
    },
    data() {
        return {
            config: {
                title: "账户余额",
                centerSlot: true,
                rightSlot: false,
                color: ["#333333"],
                statusBarFontColor: "#ffffff",
                rightBtns: [
                    {
                        id: 1,
                        type: "scan",
                    },
                ],
            },
            actions: [],
            listHeight: "",
            placeholderText: "输入账户编码、名称",
            searchForm: {
                fullName: "",
                pageNumber: 1,
                pageSize: 10,
                startDate: "",
                endDate: "",
            },
            balance: 0, // 余额
            datas: [],
        }
    },
    created() {
        let mainColor = this.easyGetColor("white")
    },
    onLoad(options) {
        if (options.balance) {
            this.balance = options.balance
        }
    },
    mounted() {
        this.getListHeight()
    },
    onShow() {
        this.init()
    },
    methods: {
        init() {
            getAccountList(this.searchForm).then((res) => {
                if (res.State == 1) {
                    this.datas = res.Data
                }
            })
        },
        getListHeight() {
            //获取商品高度
            getElementHeight(this, ".main", (e) => {
                this.listHeight = e + "px"
                // this.listHeight = e - uni.upx2px(300) + "px"
                this.loadOk = true
            })
        },
        toList(item) {
            let url = "/pages_erp/manage/accountInfo?data=" + encodeURIComponent(JSON.stringify(item))
            this.easyGoTo(url)
        },
        searchFn(key) {
            this.searchForm.fullName = key
            this.init()
        },
        waitTotalBack(e) {},
    },
}
</script>
<style lang="scss" scoped>
/deep/.searchBar .searchBar-main {
    background: #fff;
    border: 1px solid #cccccc;
}
.container {
    background: #ffffff;
    position: relative;
    height: 100vh;
}
.balance-info {
    position: relative;
    display: flex;
    height: 300rpx;
    margin: 40rpx $app-item-padding 24rpx;
    background: $app-color-main;
    border-radius: 40rpx;
    flex-flow: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    .name {
        font-size: 28rpx;
    }
    .total {
        padding: 20rpx;
        font-size: 48rpx;
        font-weight: bold;
        text {
            font-size: 20rpx;
            font-weight: normal;
        }
    }
    .acct-num {
        padding: 4rpx 24rpx;
        font-size: 26rpx;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 24rpx;
    }
    .icon-dz {
        position: absolute;
        top: 40rpx;
        left: 40rpx;
        width: 28px;
        height: 16px;
    }
}

.main {
    .list-box {
        margin: 32rpx 24rpx 0;
        .list-item {
            padding: 0 24rpx 0 32rpx;
            display: flex;
            align-items: center;
            justify-content: space-between;
            height: 128rpx;
            margin-bottom: 24rpx;
            background: #fbf6f7;
            border-radius: 28rpx;
            font-size: 30rpx;
            .name {
            }
            .con {
                flex: 1;
                display: flex;
                align-items: center;
                justify-content: flex-end;
                .num {
                    font-weight: bold;
                    font-size: 40rpx;
                }
            }
        }
    }
}
</style>
